package controller;

import java.awt.Point;
import java.util.Map;

import utils.PlayerSides;
import view.ViewController;

import model.Board;
import model.pieces.Piece;

/**
 * Class implements a player managed by user. Pieces and moves are chosen by user, data is received from the display manager object. 
 * Moves that treat the friendly King are not possible
 */
public class HumanPlayer extends Player {

	private ViewController view; // used to get user's data

	/**
	 * Constructor- create a new human-controlled player
	 * @param side- player's side
	 * @param pieces- player's pieces
	 * @param board- game board
	 * @param view- display manager
	 */
	public HumanPlayer(PlayerSides.Sides side, Map<Point, Piece> pieces, Board board, ViewController view) {
		
		// use base class's constructor
		super(side, pieces, board);
		
		// set members according to given values
		this.view = view;
	}
	
	/**
	 * Gets user's chosen move from the display manager
	 */
	@Override
	public Movement chooseMove() {

		// get chosen move
		Movement movement = view.getMovement();
		
		// return the move
		return movement;
	}
	
	/**
	 * Returns user's choice for piece to replace Pawn
	 */
	@Override
	public int getReplacingPawnOption(String[] options, int defaultOption) {
		return view.replacePawn(options, defaultOption);
	}
}